package com.example.demo.service;

import org.springframework.stereotype.Service;

import com.auth0.jwt.JWT;
import com.auth0.jwt.algorithms.Algorithm;
import com.example.demo.model.User;


@Service
public class TokenService {

	public String getToken(User user) {
		
		String token = "";
		token = JWT.create().withAudience(user.getId())	
			.sign(Algorithm.HMAC512(user.getName()));
		System.out.println("token的长度为："+token.length());
		System.out.println(token);
		return token;
	}
}
